package it.truestoryfactory.tsq.game.util;

import it.truestoryfactory.tsq.R;
import android.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class ScoreFragment extends Fragment {
	
	private View myContentView;
	private int color;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		Log.d(this.getClass().getName(), "onCreateView");
		myContentView = inflater.inflate(R.layout.score, null);
        return myContentView;
	}
	
	@Override
	public void onViewCreated(View view, Bundle savedInstanceState) {
		TextView textView = (TextView) myContentView.findViewById(R.id.myScore);
		if (textView != null){
			textView.setText("0");
			textView.setTextColor(color);
		}
		super.onViewCreated(view, savedInstanceState);
	}
	
	public void setMyColor(int color) {
		this.color = color;
	}
	
	public void setMyScoreView(int myScore) {
		TextView view = (TextView) myContentView.findViewById(R.id.myScore);
		if (view != null)
			view.setText(String.valueOf(myScore));
	}
	
	public void setTimeOutView(int timeLeft) {
		TextView view = (TextView) myContentView.findViewById(R.id.timeout);
		if (view != null)
			view.setText(String.valueOf(timeLeft));
	}

	public void setTimeOutView(String string) {
		TextView view = (TextView) myContentView.findViewById(R.id.timeout);
		if (view != null)
			view.setText(string);
	}

}
